<%--
  Created by IntelliJ IDEA.
  User: 我的大名叫陆健伟
  Date: 2016/2/29
  Time: 15:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page pageEncoding="UTF-8" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <title>12389举报中心</title>
    <link rel="stylesheet" href="<c:url value='/resource/wechat/css/frozen.css'></c:url>">
    <link rel="stylesheet" href="<c:url value='/resource/wechat/css/main.css'></c:url>">
    <style type="text/css">
        .ui-form-item label:not(.ui-switch):not(.ui-checkbox):not(.ui-radio){width: 125px; text-align: right;}
        .ui-form-item input, .ui-form-item textarea{padding-left: 125px;}
        .ui-select select{width: 90%; margin-left: 10%;}
    </style>
</head>
<body class="body_bg" ontouchstart>
<section class="ui-container">
    <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
        <label for="#" class="h1_text" style="width: 80%;color: #2775fb; font-size: 16px; text-align: left;">举报人信息</label>
    </div>
    <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
        <label for="#">举报人姓名：</label>
        <input type="text" placeholder="" value="${loginUser.realName}" readonly>
    </div>
    <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
        <c:if test="${loginUser.unit == 0}">
            <label for="#">企业代码：</label>
            <input type="text" placeholder="" value="${loginUser.orgId}" readonly>
        </c:if>
        <c:if test="${loginUser.unit == 1}">
            <label for="#">身份证号：</label>
            <input id="idCard" type="text" placeholder="" value="${loginUser.idCard}" readonly>
        </c:if>
    </div>
    <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
        <label for="#">联系方式：</label>
        <input type="text" placeholder="" value="${loginUser.mobile}" readonly>
    </div>
    <div class="ui-form-item ui-form-item-show ui-border-tb bg_fff" style="margin-top: 10px; position: relative;">
        <label for="#" class="h1_text" style="width: 80%;color: #666;font-size: 16px;text-align: left; font-weight: bold; ">请选择举报类型</label>
        <div style="position: absolute; right: 20px; top: 8px;"<label class="ui-radio" for="radio">
        <input type="radio" name="radio" id="gr_radio" checked="checked">
    </label>
        个人
        <label class="ui-radio" for="radio">
            <input type="radio" name="radio" id="dw_radio">
        </label>
        单位
    </div>
    </div>
    <div id="gr">
        <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
            <label for="#" class="h1_text" style="width: 80%;color: #2775fb; font-size: 16px;text-align: left; ">被举报人信息</label>
        </div>
        <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
            <label for="#"><span class="text_white">*</span>被举报人姓名：</label>
            <input type="text" placeholder="" id="bjbrxm" maxlength="50">
        </div>
        <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
            <label for="#"><span class="text_white">*</span>警<span class="text_white">空空空</span>号：</label>
            <input type="text" placeholder="" id="jh" maxlength="50">
        </div>
        <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
            <label for="#"><span class="text_white">*</span>被举报人单位：</label>
            <input type="text" placeholder="" id="bjbrdw" maxlength="50">
        </div>
        <div class="ui-form-item ui-border-b  bg_fff">
            <label style="color: #666;"><span class="text_red">*</span>警<span class="text_white">空	空空</span>种：</label>
            <div class="ui-select">
                <select id="grCatalogs">
                </select>
            </div>
        </div>


        <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
            <label for="#"><span class="text_white">*</span>职<span class="text_white">空空空</span>务：</label>
            <input type="text" placeholder="" id="zw" maxlength="50">
        </div>

        <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
            <label for="#"><span class="text_white">*</span>人<span class="text_white">空空空</span>数：</label>
            <input type="text" placeholder="" id="rs" maxlength="8"  onkeypress="onlyNumber()">
        </div>
        <div class="ui-btn-wrap">
            <button class="ui-btn-lg ui-btn-primary xyb" id="geren">
                下一步
            </button>
        </div>

    </div>
    <div id="dw" style="display: none;">
        <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
            <label for="#" class="h1_text" style="width: 80%;color: #2775fb; font-size: 16px;text-align: left; ">被举报单位信息</label>
        </div>
        <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
            <label for="#">单<span class="text_white">位名</span>位：</label>
            <input type="text" placeholder="" maxlength="50" id="bjbdwmc">
        </div>
        <div class="ui-form-item ui-border-b  bg_fff">
            <label style="color: #666;"><span class="text_red">*</span>警<span class="text_white">空</span>种：</label>
            <div class="ui-select">
                <select id="dwCatalogs">
                </select>
            </div>
        </div>
        <div class="ui-btn-wrap">
            <button class="ui-btn-lg ui-btn-primary xyb" id="danwei">
                下一步
            </button>
        </div>

    </div>
    </form>

</section>

<section class="ui-container" style="display: none;">

    <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
        <label for="#" class="h1_text" style="width: 80%;color: #2775fb; font-size: 16px; text-align: left;">举报内容</label>
    </div>
    <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
        <label for="#" style="width: 155px;"><span class="text_red">*</span>举报事项发生日期:</label>
        <input type="date" id="jbsxTime" style="width: 295px;  height: 30px; line-height: 30px; text-indent: 5px; padding-left: 155px">
    </div>
    <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
        <label for="#"><span class="text_red">*</span>事项名称:</label>
        <input type="text" placeholder="" id="sxmc" maxlength="100"/>
    </div>
    <div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
        <label for="#" class="h1_text" style="width: 80%;color: #2775fb; font-size: 16px; text-align: left;"><span class="text_red">*</span>举报事项经过</label>
    </div>

    <div class="bg_fff">
        <textarea id="jbsxjg"  maxlength="1000" class="ts_textarae" style="width: 90%; border: 1px solid #E0E0E0; margin-top: 10px; margin-bottom: 5px;  border-radius: 5px; margin-left: 5%; height: 180px;"></textarea>
        <p class="ts_p" id="zishu" style="width: 90%; margin-left: 5%; padding-bottom: 10px; color: #666; font-size: 14px;text-align: right;">您还可以输入1000/1000个字</p>
    </div>
    <div class="ui-btn-wrap">
        <button class="ui-btn-lg ui-btn-primary" id="complaint">
            提交
        </button>
    </div>
</section>
</body>
<script src="<c:url value='/resource/js/jquery-2.0.min.js'/>"></script>
<script type="text/javascript">
    $(function() {
        $("#gr_radio").click(function() {
            $("#gr").show();
            $("#dw").hide();

        })
        $("#dw_radio").click(function() {
            $("#gr").hide();
            $("#dw").show();

        })

        var idCard = $("#idCard").val();
        $("#idCard").val(idCard.substring(0,6) + "***********" + idCard.substring(17));


        var unit = "${loginUser.unit}";

        $.ajax({
            url : "<c:url value='/api/query/police-catalogsAll'/>",
            type : "get",
            dataType : "json",
            success : function(resp){
                if(resp&&resp.succ){
                    var _data = resp.data,_length = _data.length;
                    var _html = "";
                    for(var i=0;i<_length;i++){
                        var _item = _data[i];
                        if(i == 0){
                            _html += "<option selected='true' value='"+ _item.iD+"-"+_item.name + "'>" + _item.name + "</option>";
                        }else {
                            _html += "<option value='"+ _item.iD+"-"+_item.name + "'>" + _item.name + "</option>";
                        }
                    }
                    $("#grCatalogs").html(_html);
                    $("#dwCatalogs").html(_html);
                }
            }
        });

        $("#geren").click(function(){
            if($("#rs").val() != ""){
                for(var i=0;i<$("#rs").val().length;i++){
                    if(i == 0){
                        if($("#rs").val().substring(i,i+1) == "0"){
                            alert("人数首位不能为0");
                            return;
                        }
                    }
                    if("1234567890".indexOf($("#rs").val().substring(i,i+1))==-1){
                        alert("请输入正确的人数");
                        return;
                    }
                }
            }
//            if($("#bjbrxm").val() == ""){
//                alert("请输入被举报人姓名");
//                return;
//            }
//            if($("#zw").val() == ""){
//                alert("请输入职务");
//                return;
//            }
//            if($("#bjbrdw").val() == ""){
//                alert("请输入被举报人单位");
//                return;
//            }
//            if($("#rs").val() == ""){
//                alert("请输入人数");
//                return;
//            }
            $(".ui-container").first().hide();
            $(".ui-container").last().show();
        });

        $("#danwei").click(function(){
//            if($("#bjbdwmc").val() == ""){
//                alert("请输入单位名称");
//                return;
//            }
            $(".ui-container").first().hide();
            $(".ui-container").last().show();
        });

        $("#jbsxjg").keyup(function(){
            $("#zishu").html("您还可以输入"+(1000-$(this).val().length)+"/1000个字");
        })


        $("#complaint").click(function(){
            if($("#jbsxTime").val() == ""){
                alert("请输入举报事项发生日期!");
                return;
            }
            if(Date.parse($("#jbsxTime").val()) > new Date()){
                alert("举报事项发生日期不能大于当前日期!");
                return;
            }
            if($("#sxmc").val() == ""){
                alert("请输入事项名称!");
                return;
            }
            if($("#jbsxjg").val() == ""){
                alert("请输入举报事项经过!");
                return;
            }
            var unitNumber = "";
            var jzmc = "";
            var type = "";

            var jbsxTime = changeTime($("#jbsxTime").val());
//            alert(jbsxTime);
            if($("#gr_radio")[0].checked == true){
                jzmc = $("#grCatalogs").val();
                type = 0;
            }else if($("#dw_radio")[0].checked == true){
                jzmc = $("#dwCatalogs").val();
                type = 1;
            }
            if(unit == 1){
                unitNumber = "${loginUser.idCard}";
            }
            else {
                unitNumber = "${loginUser.orgId}";
            }
            $.ajax({
                type : "post",
                url : "<c:url value='/api/complaint/proinfo/center'/>",
                data : {"unitAttribute":unit,"jbsxjg":$("#jbsxjg").val(),"jbsxTime":jbsxTime,"sxmc":$("#sxmc").val(),"bjbdwmc":$("#bjbdwmc").val(),"bjbrxm":$("#bjbrxm").val(),"zw":$("#zw").val(),"bjbrdw":$("#bjbrdw").val(),"rs":$("#rs").val(),"unitName":"${loginUser.realName}","unitNumber":unitNumber,"unitAddress":"${loginUser.address}","handPhone":"${loginUser.mobile}","userGuid":"${loginUser.guid}","jzmc":jzmc,"type":type,"jh":$("#jh").val(),"pt":"${pt}"},
                dataType : "json",
                async : false,
                success : function(resp){
                    if(resp&&resp.succ){
                        alert(resp.msg);
                        window.location.href = "<c:url value='/api/complaint/itComplt?pt=${pt}'/>";
                    }
                }
            });
        });
    })

    function changeTime(time){
        var newTime = "";
        var first = time.indexOf("-");
        newTime += time.substring(0,first) + "/";
        var last = time.lastIndexOf("-");
        newTime += time.substring(first+1,last) + "/";
        newTime += time.substring(last+1);
        return newTime;
    }

    function onlyNumber(){
        if ((event.keyCode <48) || (event.keyCode> 57 )) event.returnValue = false;
    }



</script>
</html>
